<?

//Initiate Authenticate
SecurityRedirect ();

//initiate Vars
define("PRIMARY_KEY","nobkt");
$KEY[]         = array("PRIMARY_KEY"=>PRIMARY_KEY);
$FileName      = "ais_report_custarsettle.php";
$FileTemplate  = "ais_report_custarsettle_list.html";
$TableName     = "ais_piutang";
$SubHeaderTitle= "Report - AR Settlement";
$PageSize      = 10;
$HTMLGridList  = "ARSettlement";

//************ FORM ACTION **************
$periodYear  = GetParam("periodYear","");
$periodMonth = GetParam("periodMonth","");

//******* SHOW FORM CONTENT *********
$TBS = new clsTinyButStrong;
$TBS->LoadTemplate($MOD_TEMPLATE_DIR."/".$FileTemplate);
$TBS->MergeBlock("monthformblk",GetArrayMonth());
$SQLOffice = "SELECT * FROM tblkantor";
$TBS->MergeBlock("officeformblk",$DBMysql,$SQLOffice);
$TBS->MergeBlock("yearformblk",GetArrayYear());
$SQL = "SELECT distinct skada,namacc FROM tblcoa WHERE (".GetAgingARCondition().") AND tipe=0 ORDER BY skada ";
//echo($SQL);
$TBS->MergeBlock("fromskadaformblk",$DBConnection->GetConnection1(),$SQL);
$TBS->MergeBlock("toskadaformblk",$DBConnection->GetConnection1(),$SQL);
$SQL = "SELECT * FROM tblcurrency ";
$TBS->MergeBlock("currblk",$DBConnection->GetConnection1(),$SQL);
$TBS->Show();

function GetAgingARCondition() {
	global $DBConnection;
	$SQL = "SELECT araging FROM tblprofile WHERE ktrasl='".GetOfficeID()."' ";
	$ARAging = $DBConnection->dbc->get_var($SQL);
	$condition = array();
	foreach (explode(" ",$ARAging) as $skada) {
	   if(trim($skada) == '') continue;
	   $condition[] = "skada LIKE '$skada%'";
	}
	return implode(" OR ",$condition);
}

?>